<html>
<META http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<head>
<title>Section 12.2.&nbsp; Thread Limits</title>
<link rel="STYLESHEET" type="text/css" href="images/style.css">
<link rel="STYLESHEET" type="text/css" href="images/docsafari.css">
</head>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch12lev1sec1.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch12lev1sec3.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
<br><table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top"><a name="ch12lev1sec2"></a>
<h3 class="docSection1Title">12.2. Thread Limits</h3>
<p class="docText">We discussed the <tt>sysconf</tt> function in <a class="docLink" href="ch02lev1sec5.html#ch02lev2sec15">Section 2.5.4</a>. The Single UNIX Specification defines several limits associated with the operation of threads, which we didn't show in <a class="docLink" href="ch02lev1sec5.html#ch02fig10">Figure 2.10</a>. As with other system limits, the thread limits can be queried using <tt>sysconf</tt>. <a class="docLink" href="#ch12fig01">Figure 12.1</a> summarizes these limits.</P>
<a name="ch12fig01"></a><P><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><h5 class="docTableTitle">Figure 12.1. Thread limits and <span class="docEmphasis">name</span> arguments to <tt>sysconf</tt></H5></caption><colgroup><col width="100"><col width="350"><col width="100"></colgroup><thead><TR><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman">Name of limit</span></P></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman">Description</span></p></th><th class="bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman"><span class="docEmphasis">name</span> argument</span></P></th></TR></thead><TR><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>PTHREAD_DESTRUCTOR_ITERATIONS</tt></P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">maximum number of times an implementation will try to destroy the thread-specific data when a thread exits (<a class="docLink" href="ch12lev1sec6.html#ch12lev1sec6">Section 12.6</a>)</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>_SC_THREAD_DESTRUCTOR_ITERATIONS</tt></P></TD></tr><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>PTHREAD_KEYS_MAX</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">maximum number of keys that can be created by a process (<a class="docLink" href="ch12lev1sec6.html#ch12lev1sec6">Section 12.6</a>)</p></TD><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>_SC_THREAD_KEYS_MAX</tt>
</P></td></TR><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>PTHREAD_STACK_MIN</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">minimum number of bytes that can be used for a thread's stack (<a class="docLink" href="ch12lev1sec3.html#ch12lev1sec3">Section 12.3</a>)</p></td><td class="docTableCell" align="left" valign="top"><p class="docText"><tt>_SC_THREAD_STACK_MIN</tt></p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>PTHREAD_THREADS_MAX</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">maximum number of threads that can be created in a process (<a class="docLink" href="ch12lev1sec3.html#ch12lev1sec3">Section 12.3</a>)</p></TD><TD class="docTableCell" align="left" valign="top"><p class="docText"><tt>_SC_THREAD_THREADS_MAX</tt></p></TD></TR></table></P><br>
<p class="docText">As with the other limits reported by <tt>sysconf</tt>, use of these limits is intended to promote application portability among different operating system implementations. For example, if your application requires that you create four threads for every file you manage, you might have to limit the number of files you can manage concurrently if the system won't let you create enough threads.</P>
<p class="docText"><a name="idd1e85574"></a><a name="idd1e85579"></a><a name="idd1e85584"></a><a name="idd1e85589"></a><a name="idd1e85594"></a><a name="idd1e85599"></a><a name="idd1e85604"></a><a name="idd1e85609"></a><a name="idd1e85614"></a><a name="idd1e85619"></a><a name="idd1e85624"></a><a class="docLink" href="#ch12fig02">Figure 12.2</a> shows the values of the thread limits for the four implementations described in this book. When the implementation doesn't define the corresponding <tt>sysconf</tt> symbol (starting with <tt>_SC_</tt>), &quot;no symbol&quot; is listed. If the implementation's limit is indeterminate, &quot;no limit&quot; is listed. This doesn't mean that the value is unlimited, however. An &quot;unsupported&quot; entry means that the implementation defines the corresponding <tt>sysconf</tt> limit symbol, but the <tt>sysconf</tt> function doesn't recognize it.</P>
<blockquote>
<p class="docText">Note that although an implementation may not provide access to these limits, that doesn't mean that the limits don't exist. It just means that the implementation doesn't provide us with a way to get at them using <tt>sysconf</tt>.</P>
</blockquote>
<a name="ch12fig02"></a><p><table cellspacing="0" class="allBorders" border="1" RULES="groups" cellpadding="5"><caption><H5 class="docTableTitle">Figure 12.2. Examples of thread configuration limits</h5></caption><colgroup><col width="180"><col width="80"><col width="80"><col width="80"><col width="70"></colgroup><thead><TR><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="middle"><p class="docText"><span class="docEmphRoman">Limit</span></P></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman">FreeBSD 5.2.1</span></P></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman">Linux 2.4.22</span></p></th><th class="rightBorder bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman">Mac OS X 10.3</span></P></th><th class="bottomBorder thead" scope="col" align="center" valign="bottom"><p class="docText"><span class="docEmphRoman">Solaris 9</span></P></th></tr></thead><TR><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>PTHREAD_DESTRUCTOR_ITERATIONS</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">no symbol</p></TD><td class="rightBorder" align="left" valign="top"><p class="docText">unsupported</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">no symbol</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">no limit</p></td></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>PTHREAD_KEYS_MAX</tt></p></td><td class="rightBorder" align="left" valign="top"><p class="docText">no symbol</p></td><td class="rightBorder" align="left" valign="top"><p class="docText">unsupported</p></td><td class="rightBorder" align="left" valign="top"><p class="docText">no symbol</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">no limit</P></TD></TR><tr><TD class="rightBorder" align="left" valign="top"><p class="docText"><tt>PTHREAD_STACK_MIN</tt></P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">no symbol</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">unsupported</P></TD><td class="rightBorder" align="left" valign="top"><p class="docText">no symbol</P></TD><td class="docTableCell" align="left" valign="top"><p class="docText">4,096</P></TD></tr><tr><td class="rightBorder" align="left" valign="top"><p class="docText"><tt>PTHREAD_THREADS_MAX</tt></p></TD><td class="rightBorder" align="left" valign="top"><p class="docText">no symbol</P></td><TD class="rightBorder" align="left" valign="top"><p class="docText">unsupported</p></td><td class="rightBorder" align="left" valign="top"><p class="docText">no symbol</p></td><td class="docTableCell" align="left" valign="top"><p class="docText">no limit</p></td></tr></table></p><br>

<a href="17021535.html"><img src="images/pixel.gif" alt="" width="1" height="1" border="0"></a><ul></ul></td></tr></table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr><td><div STYLE="MARGIN-LEFT: 0.15in;"><a href="toc.html"><img src="images/team.gif" width="60" height="17" border="0" align="absmiddle"  alt="Team BBL"></a></div></td>
<td align="right"><div STYLE="MARGIN-LEFT: 0.15in;">
<a href=ch12lev1sec1.html><img src="images/prev.gif" width="60" height="17" border="0" align="absmiddle" alt="Previous Page"></a>
<a href=ch12lev1sec3.html><img src="images/next.gif" width="60" height="17" border="0" align="absmiddle" alt="Next Page"></a>
</div></td></tr></table>
</body></html><br>
<table width="100%" cellspacing="0" cellpadding="0"
style="margin-top: 0pt; border-collapse: collapse;"> 
<tr> <td align="right" style="background-color=white; border-top: 1px solid gray;"> 
<a href="http://www.zipghost.com/" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">The CHM file was converted to HTM by Trial version of <b>ChmD<!--239-->ecompiler</b>.</a>
</TD>
</TR><tr>
<td align="right" style="background-color=white; "> 
<a href="http://www.etextwizard.com/download/cd/cdsetup.exe" target="_blank" style="font-family: Tahoma, Verdana;
 font-size: 11px; text-decoration: none;">Download <b>ChmDec<!--239-->ompiler</b> at: http://www.zipghost.com</a>
</TD></tr></table>
